<?php

namespace app\api\service;

class Token
{
    /**
     * 生成token
     * @return string
     */
    public static function generateToken()
    {
        // 1.32位的随机字符串
        $randChars = rand_char(32);
        // 2.时间戳
        $timestamp = $_SERVER['REQUEST_TIME_FLOAT'];
        // 3.盐
        $salt = config('app.secure.token_salt');
        // 用三组字符串，进行md5加密 [加强安全性]
        return md5($randChars . $timestamp . $salt);
    }
}